Silk Mobile

Table of Contents (Homepage)

Using JUnit

We will now demonstrate how to export the JUnit4 rendition of our test script to a Java environment, where we will edit and then run it. Once again, the test script being used in this example is that prepared for the eri-Bank application in Session 2.

Perform the following steps:

Step 1: With the test script from Session 2 loaded in the Silk Mobile, click the Code tab directly below the script display.

Step 2: From the popup list, select the language in which the script is to be rendered. In this example, we will choose Java (junit4).

images/download/attachments/2687924/1.jpg

Step 3: Copy the entire junit4 rendition of the script to your clipboard by clicking the Copy to Clipboard icon.

images/download/attachments/2687924/2.jpg

Step 4: Paste the code you have just copied into an Eclipse shell.

images/download/attachments/2687924/withoutWhileLoop.png

Step 5: Within Eclipse, add the Silk Mobile's JARs into the project.

  1. Right-click the project's Sandbox folder and choose the Properties command.
    images/download/attachments/2687924/4.jpg

  2. In the Properties for Sandbox dialog box now displayed, select Java Build Path in the pane on the left side of the window and click the Add External JARs button.
    images/download/attachments/2687924/5.jpg

  3. Navigate to the Silk Mobile folder, and from there go to Clients->Java, select all 5 JARs, and click OK.
    images/download/attachments/2687924/6.jpg

Step 6: Modify the JUnit4 rendition of the test script, creating a loop which will cause the test to be run 100 times, as depicted below.

images/download/attachments/2687924/Capture.PNG

Step 7: Run the test by clicking the Play button. (If necessary, change the value of the public class so that it will match the class name.)

images/download/attachments/2687924/8.jpg